#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include "client_manager.h"

#define MAX_CLIENTS 100

//typedef struct {
//    char ip[INET_ADDRSTRLEN];
//    char ota_state[20];
//} Client;

static Client connected_clients[MAX_CLIENTS];
static int client_count = 0;

void add_client(const char *ip) {
    if (client_count < MAX_CLIENTS) {
        strncpy(connected_clients[client_count].ip, ip, INET_ADDRSTRLEN);
        strncpy(connected_clients[client_count].ota_state, "OTA_STATE_IDLE", sizeof(connected_clients[client_count].ota_state));
        client_count++;
    }
}

Client* get_clients(int *count) {
    *count = client_count;
    return connected_clients;
}

void clear_clients() {
    client_count = 0;
    memset(connected_clients, 0, sizeof(connected_clients));
}